package com.xxxx.sink_operator;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;

import java.util.Arrays;
import java.util.List;

/**
 * @program: flink19Test
 * @description:
 * @author: CoreDao
 * @create: 2021-04-01 17:56
 **/

public class SinkAddSink {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();


        List<String> list = Arrays.asList("hello nihao", "hello nihao2", "hello nihao3");

        DataStreamSource<String> dataStreamSource = env.fromCollection(list);

        dataStreamSource.addSink(new SinkFunction<String>() {
            @Override
            public void invoke(String value) throws Exception {
                System.out.println(value);
            }
        });


        System.out.println(env.getExecutionPlan());
        env.execute();
    }
}
